﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using Database.Classes;


public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void RestartGame()
    {
        using (SqlConnection conn = new SqlConnection(StaticMethods.ConnectionString()))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand(@"Delete from News", conn))
            {
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete from fleets";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete from Logs";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete from Battles";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete from Planets";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete  from AllianceMembers";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete  from Alliances";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete  from Artifacts";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete  from Players Where PlayerId > 1";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete  from Intel";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete  from Systems";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Drop TABLE Systems";
                cmd.ExecuteNonQuery();
                cmd.CommandText = @"CREATE TABLE [dbo].[Systems](
	                [SystemID] [int] IDENTITY(1,1) NOT NULL,
	                [SystemName] [nvarchar](50) COLLATE Polish_CI_AS NOT NULL,
	                [X] [int] NOT NULL,
	                [Y] [int] NOT NULL)";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Update Configuration set PlayersInLastSystem = 0, LastOrginID = 1, SupplyUnitsPrice= 1500";
                cmd.ExecuteNonQuery();
            }
        }
        CreateGame();
    }

};
